﻿using System;
using System.Text;
using System.Data;
using BLL;
using Utils;
namespace UI.ModSalary
{
    public partial class SalaryPrintSlip : System.Web.UI.Page
    {
        string setsID = "";
        string strYear = "";
        string strMonth = "";
        SalaryTableBiz salaryTableBiz = new SalaryTableBiz();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["SetsID"] != null)
            {
                setsID = Request.Params["SetsID"].ToString();
                strYear = Request.Params["StrYear"].ToString();
                strMonth = Request.Params["StrMonth"].ToString();
            }
            if (strYear == "" || strMonth == "")
            {
                JSUtility.Alert(this, "参数错误 ");
                return;
            }
            if (!IsPostBack)
            {
                BondData();
            }
        }

        private void BondData()
        {
           
            DataTable dt = salaryTableBiz.GetLists(strYear, strMonth, setsID);
            ExcelUtility.ExportToXls(this, dt);
            // string strHead=GetHead(dt);

            // StringBuilder builderAll = new StringBuilder();
            
            //for (int j=0;j<dt.Rows.Count;j++)
            //{
            //    StringBuilder builder = new StringBuilder();
            //    builder.Append("<tr >");
            //    for (int i = 0; i < dt.Columns.Count; i++)
            //    {
            //        builder.Append("<td >" + dt.Rows[j][dt.Columns[i].ColumnName].ToString() + "</td>");
            //    }
            //    builder.Append("</tr>");
            //    builderAll.Append("<table class=\"tbPrint\" >");
            //    builderAll.Append(strHead);
            //    builderAll.Append(builder);
            //    builderAll.Append("</table>");
            //}
            //lt1.Text = builderAll.ToString();


        }
        //获取表头
        private string GetHead(DataTable dt)
        {
            StringBuilder builder = new StringBuilder("<tr>");
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                builder.Append("<td>" + dt.Columns[i].ColumnName + "</td>");
            }
            builder.Append("</tr>");
            return builder.ToString();
        }
    }
}